/**
 * 
 */
package sistema.contexto.linguagem;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;

import sistema.contexto.AvaliacaoBLFacade;



/**
 * @author Thiago Emmanuel Pereira da Cunha Silva, thiago.manel@gmail.com
 * @since 15/04/2006
 */
public class LinguagemTUI {

	@SuppressWarnings("static-access")
	public static void main(String args[]) {
		Option identificadorOption = OptionBuilder.
														withArgName("identificador")
														.hasArg()
														.withDescription("identificador da liguagem")
														.create("id");
		
		Option comCompOption = OptionBuilder.
														withArgName("comComp")
														.hasArg()
														.withDescription("comando de compilacao")
														.create("comComp");
		
		Option comExecOption = OptionBuilder.
																withArgName("comExec")
																.hasArg()
																.withDescription("comando de execucao")
																.create("comExec");
		
		Option compl = OptionBuilder.
																withArgName("compl")
																.hasArg()
																.withDescription("descricao complementar")
																.create("compl");
		
		Options options = new Options();
		options.addOption(identificadorOption);
		options.addOption(comCompOption);
		options.addOption(comExecOption);
		options.addOption(compl);
		options.addOption("lista", true , "lista  Linguagens");
		
		HelpFormatter formatter = new HelpFormatter();
		formatter.printHelp( "caos", options );
		
		CommandLineParser parser = new PosixParser();
	    try {
	        CommandLine line = parser.parse( options, args );
	        new AvaliacaoBLFacade().criaLinguagem(line.getOptionValue( "id"),
	        																  line.getOptionValue( "comComp"), line.getOptionValue( "comExec"), 
	        																  line.getOptionValue( "compl"));
	        if(line.hasOption("lista")){
	        	System.out.println(new AvaliacaoBLFacade().listaLinguagens());
	        }
	    }
	    catch( ParseException exp ) {
	        System.err.println( "Parsing failed.  Reason: " + exp.getMessage() );
	    }
		
	}
}
